Page({

  /**
   * 页面的初始数据
   */
  data: {
    inputShowed: false,
    inputVal: "",
    //左边菜单列表
    types:[
      { id: 1, name: "初中" },
      { id: 2, name: "高中" },
      { id: 3, name: "小学" },
      { id: 4, name: "艺术" },
      { id: 5, name: "大学/成人" },
      { id: 6, name: "学龄前" }
    ],
    currType:1,
    goodsList:[
      { id:1,
        name: "初中",
        goodsItem:[
          { goodsId: 11, name: "初中数学", ad:"https://wx2.sinaimg.cn/mw690/007eALKxly1gmkp0o4785j30yg0ljn15.jpg"},
          { goodsId: 12, name: "初中科学", ad:"https://wx3.sinaimg.cn/mw690/007eALKxly1gmkp1tbxzfj30b408caai.jpg"},
          { goodsId: 13, name: "初中英语", ad:"https://wx2.sinaimg.cn/mw690/007eALKxly1gmkp0hy9kyj30rs0gt0vw.jpg"},
          { goodsId: 14, name: "初中语文", ad:"https://wx3.sinaimg.cn/mw690/007eALKxly1gmkp1zh66zj30hs0ataac.jpg"},
          { goodsId: 15, name: "初中其他", ad:"https://wx4.sinaimg.cn/mw690/007eALKxly1gmkp6upqrnj30xc0jqjv0.jpg" },
          { goodsId: 16, name: "初中答疑", ad:"https://wx4.sinaimg.cn/mw690/007eALKxly1gmkp6pk18fj30dw09ujsd.jpg"}
        ]
      },
      {
        id: 2,
        name: "高中",
        goodsItem: [
          { goodsId: 21, name: "高中数学", ad:"https://wx2.sinaimg.cn/mw690/007eALKxly1gmkp0o4785j30yg0ljn15.jpg"},
          { goodsId: 22, name: "高中英语", ad:"https://wx2.sinaimg.cn/mw690/007eALKxly1gmkp0hy9kyj30rs0gt0vw.jpg"},
          { goodsId: 23, name: "高中语文", ad:"https://wx3.sinaimg.cn/mw690/007eALKxly1gmkp1zh66zj30hs0ataac.jpg" },
          { goodsId: 24, name: "高中其他", ad:"https://wx4.sinaimg.cn/mw690/007eALKxly1gmkp6upqrnj30xc0jqjv0.jpg"},
        ]
      },
      {
        id: 3,
        name: "小学",
        goodsItem: [
          { goodsId: 31, name: "小学数学", ad:"https://wx2.sinaimg.cn/mw690/007eALKxly1gmkp0o4785j30yg0ljn15.jpg"},
          { goodsId: 32, name: "小学英语", ad:"https://wx2.sinaimg.cn/mw690/007eALKxly1gmkp0hy9kyj30rs0gt0vw.jpg"},
          { goodsId: 33, name: "小学语文", ad:"https://wx3.sinaimg.cn/mw690/007eALKxly1gmkp1zh66zj30hs0ataac.jpg"},
          { goodsId: 34, name: "小学其他", ad:"https://wx4.sinaimg.cn/mw690/007eALKxly1gmkp6upqrnj30xc0jqjv0.jpg" },
        ]
      },
      {
        id: 4,
        name: "艺术",
        goodsItem: [
          { goodsId: 41, name: "钢琴", ad:"https://wx4.sinaimg.cn/mw690/007eALKxly1gmkp1pq6l0j30go0b4aaz.jpg"},
          { goodsId: 42, name: "民乐", ad:"https://wx1.sinaimg.cn/mw690/007eALKxly1gmkp0ucawlj30u00j4did.jpg"},
          { goodsId: 43, name: "绘画", ad:"https://wx3.sinaimg.cn/mw690/007eALKxly1gmkp0d91mnj30e809hjt6.jpg"},
          { goodsId: 44, name: "舞蹈", ad:"https://wx3.sinaimg.cn/mw690/007eALKxly1gmkp07atntj30hy0bzjrt.jpg"},
        ]
      },
      {
        id: 5,
        name: "大学/成人",
        goodsItem: [
          { goodsId: 51, name: "英语", ad:"https://wx2.sinaimg.cn/mw690/007eALKxly1gmkp0hy9kyj30rs0gt0vw.jpg"},
          { goodsId: 52, name: "考研", ad:"https://wx3.sinaimg.cn/mw690/007eALKxly1gmkphdr7p1j30b40fsgnl.jpg" },
          { goodsId: 53, name: "CPA", ad:"https://wx2.sinaimg.cn/mw690/007eALKxly1gmkphizy12j30c408iwef.jpg"},
          { goodsId: 54, name: "计算机", ad:"https://wx1.sinaimg.cn/mw690/007eALKxly1gmkp6j0pyij30h80bhq3g.jpg" },
        ]
      },
      {
        id: 6,
        name: "学龄前",
        goodsItem: [
          { goodsId: 61, name: "幼儿英语", ad:"https://wx2.sinaimg.cn/mw690/007eALKxly1gmkp0hy9kyj30rs0gt0vw.jpg" },
          { goodsId: 62, name: "幼儿数学", ad:"https://wx2.sinaimg.cn/mw690/007eALKxly1gmkp0o4785j30yg0ljn15.jpg" },
          { goodsId: 63, name: "幼儿识字", ad:"https://wx3.sinaimg.cn/mw690/007eALKxly1gmkph73mwnj30ku0fmzkw.jpg" }
        ]
      },
    ]
  },
  onLoad() {
    this.setData({
      search: this.search.bind(this)
    })

  },
  search: function (value) {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        resolve([{ text: '搜索结果', value: 1 }, { text: '搜索结果2', value: 2 }])
      }, 200)
    })
  },
  selectResult: function (e) {
    console.log('select result', e.detail)
  },
  tapType:function(e){
    var that = this;
    const currType = e.currentTarget.dataset.typeid;
    that.setData({
      currType: currType
    });
  },

 tapView:function(e){
   var that=this;
   //这个是必须的，不然会报错！！！
   const goods_name = e.currentTarget.dataset.name;
   const goods_ad = e.currentTarget.dataset.ad;
   var goodsList=JSON.stringify(that.data.goodsList);
   wx.navigateTo({
     url: '../detail/detail?goodsDetail='+goodsList+'&header='+goods_name+'&ad='+goods_ad
   })
 }
})
